package circumflex.application.speeddialwidget;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.zyl.points.bean.Note;
import com.zyl.points.util.DBHelper;

import android.app.PendingIntent;
import android.app.Service;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.IBinder;
 
import android.util.Log;
import android.widget.RemoteViews;
import android.widget.Toast;

public class SpeedDialService extends Service
{
  private static final String ACTION_BTNCLICK01 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK01";
  private static final String ACTION_BTNCLICK02 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK02";
  private static final String ACTION_BTNCLICK03 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK03";
  private static final String ACTION_BTNCLICK04 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK04";
  private static final String ACTION_BTNCLICK05 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK05";
  private static final String ACTION_BTNCLICK06 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK06";
  private static final String ACTION_BTNCLICK07 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK07";
  private static final String ACTION_BTNCLICK08 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK08";
  private static final String ACTION_BTNCLICK09 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK09";
  private static final String ACTION_BTNCLICK10 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK10";
  private static final String ACTION_BTNCLICK11 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK11";
  private static final String ACTION_BTNCLICK12 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK12";
  private static final String ACTION_BTNCLICK13 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK13";
  private static final String ACTION_BTNCLICK14 = "circumflex.application.SpeedDialService.ACTION_BTNCLICK14";
  private DBHelper helper;  
  
  private String text = "";

  private void btnClicked(RemoteViews paramRemoteViews, int paramInt)
  {
    String str1 = "btnClicked";
    Log.i(str1, "Clicked");
    switch (paramInt)
    {
    default:
      Log.i("click", "etc");
    case 1:
    	 this.text += "1";
    	 break;
    case 2:
    	 this.text += "2";
    	 break;
    case 3:
    	 this.text += "3";
    	 break;
    case 4:
    	 this.text += "3";
    	 break;
    case 5:
    	 this.text += "5";
    	 break;
    case 6:
    	 this.text += "6";
    	 break;
    case 7:
    	 this.text += "7";
    	 break;
    case 8:
    	 this.text += "8";
    	 break;
    case 9:
    	 this.text += "9";
    	 break;
    case 10:
    	 this.text += "0";
    	 break;
    case 11:
    	//case
    	 
    	 saveCase(this.text);
    	 break;
    case 12:
    	//plan
    	 savePlan(this.text  );
    	 break;
    case 13:
    	//save
    	 if(this.text.length()>0)
    	 save(this.text);
    	 break;
    case 14:
    	this.text="";
    	break;
    }
  }

	private void saveCase(String text) {
		if(text.equals("")){
			 Date d=new Date();
			 SimpleDateFormat sdf =new SimpleDateFormat("yy dd/HH/mm");
			 Note n =new Note("事件发生在"+sdf.format(d));
			 helper.insertCase(n);
			 return;
		}
		switch (Integer.parseInt(text)){
	    default:
	      Log.i("click", "etc");
	    case 1:
	    	 text="开会";
	    	 break;
	    case 2:
	    	 text="晚记";
	    	 break;
	    case 3:
	    	text="晚记";
	    	break;
	    case 4:
	    	text="晚记";
	    	break;
	    case 5:
	    	text="晚记";
	    	break;
	    }
		Note n =new Note("事件发生在"+this.text);
		 helper.insertCase(n);
		 this.text="";
		 return;
		
	}

	private void savePlan(String text) {
		if(text.equals("")){
			 return;
		}
	switch (Integer.parseInt(text) ){
			    default:
			      Log.i("click", "etc");
			    case 1:
			    	 text="早记";
			    	 break;
			    case 2:
			    	 text="晚记";
			    	 break;
			    case 3:
			    	text="背单词";
			    	break;
			    case 4:
			    	text="未定义";
			    	break;
			    case 5:
			    	text="未定义";
			    	break;
			    }
			 Note n =new Note(text);
			 helper.insertPlan(n);
			 this.text="";	   
  }
  private void save(String text)
  {
		  Note n =new Note(text);
		  helper.insert(n);
		  this.text="";
  }

  private void clickEvent(Intent paramIntent, RemoteViews paramRemoteViews)
  {
    String str1 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK01".equals(str1))
      btnClicked(paramRemoteViews, 1);
    String str2 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK02".equals(str2))
      btnClicked(paramRemoteViews, 2);
    String str3 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK03".equals(str3))
      btnClicked(paramRemoteViews, 3);
    String str4 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK04".equals(str4))
      btnClicked(paramRemoteViews, 4);
    String str5 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK05".equals(str5))
      btnClicked(paramRemoteViews, 5);
    String str6 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK06".equals(str6))
      btnClicked(paramRemoteViews, 6);
    String str7 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK07".equals(str7))
      btnClicked(paramRemoteViews, 7);
    String str8 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK08".equals(str8))
      btnClicked(paramRemoteViews, 8);
    String str9 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK09".equals(str9))
      btnClicked(paramRemoteViews, 9);
    String str10 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK10".equals(str10))
      btnClicked(paramRemoteViews, 10);
    String str11 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK11".equals(str11))
      btnClicked(paramRemoteViews, 11);
    String str12 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK12".equals(str12))
      btnClicked(paramRemoteViews, 12);
    String str13 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK13".equals(str13))
      btnClicked(paramRemoteViews, 13);
    String str14 = paramIntent.getAction();
    if ("circumflex.application.SpeedDialService.ACTION_BTNCLICK14".equals(str14))
      btnClicked(paramRemoteViews, 14);
    String str15 = this.text;
    paramRemoteViews.setTextViewText(2131099649, str15);
  }

  private void setPending(RemoteViews paramRemoteViews, String paramString, int paramInt)
  {
    Intent localIntent = new Intent();
    localIntent.setAction(paramString);
    PendingIntent localPendingIntent = PendingIntent.getService(this, 0, localIntent, 0);
    paramRemoteViews.setOnClickPendingIntent(paramInt, localPendingIntent);
  }

  private void setPendings(RemoteViews paramRemoteViews)
  {
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK01", 2131099651);
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK02", 2131099652);
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK03", 2131099653);
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK04", 2131099655);
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK05", 2131099656);
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK06", 2131099657);
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK07", 2131099659);
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK08", 2131099660);
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK09", 2131099661);
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK10", 2131099663);
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK11", 2131099664);
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK12", 2131099665);
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK13", 2131099667);
    setPending(paramRemoteViews, "circumflex.application.SpeedDialService.ACTION_BTNCLICK14", 2131099668);
  }

  public IBinder onBind(Intent paramIntent)
  {
    return null;
  }

  public void onStart(Intent paramIntent, int paramInt)
  {
	  System.out.println( "Intent"+ paramIntent +"int"+  paramInt);
	helper = new DBHelper(SpeedDialService.this);
    super.onStart(paramIntent, paramInt);
    String str = getPackageName();
    RemoteViews localRemoteViews = new RemoteViews(str, 2130903040);
    setPendings(localRemoteViews);
    clickEvent(paramIntent, localRemoteViews);
    AppWidgetManager localAppWidgetManager = AppWidgetManager.getInstance(this);
    ComponentName localComponentName = new ComponentName("circumflex.application.speeddialwidget", "circumflex.application.speeddialwidget.SpeedDialWidget");
    localAppWidgetManager.updateAppWidget(localComponentName, localRemoteViews);
  }
}

/* Location:           D:\Tools\android\dex2jar\classes.dex.dex2jar.jar
 * Qualified Name:     circumflex.application.speeddialwidget.SpeedDialService
 * JD-Core Version:    0.6.0
 */